﻿#region 信息

// Copyright©2014 Rex Rao all rights reserved.
// File name : SoMcCoffee\Sohobloo.SoCommon\OperationResult.cs
// Author : Sohobloo
// Create time : 2014/01/24 16:58
// Update time : 2014/02/07 17:45

#endregion

#region 引用

using System;
using System.Globalization;

#endregion

namespace Sohobloo.SoCommon
{
    public class OperationResult
    {
        #region 属性

        public object AppendData { get; set; }

        public string Message { get; set; }

        public int ResultCode { get; set; }

        public OperationResultType ResultType
        {
            get
            {
                OperationResultType resultType;
                if(!Enum.TryParse(ResultCode.ToString(CultureInfo.InvariantCulture), out resultType))
                {
                    resultType = OperationResultType.UserDefine;
                }
                return resultType;
            }
        }

        #endregion 属性

        #region 构造

        public OperationResult(OperationResultType resultType)
        {
            ResultCode = (int)resultType;
        }

        public OperationResult(int resultCode)
        {
            ResultCode = resultCode;
        }

        public OperationResult(OperationResultType resultType, string message)
            : this(resultType)
        {
            Message = message;
        }

        public OperationResult(int resultCode, string message)
            : this(resultCode)
        {
            Message = message;
        }

        public OperationResult(OperationResultType resultType, string message, object appendData)
            : this(resultType, message)
        {
            AppendData = appendData;
        }

        public OperationResult(int resultCode, string message, object appendData)
            : this(resultCode, message)
        {
            AppendData = appendData;
        }

        #endregion 构造
    }
}